-- damage_by_floor
-- created by panyl
-- 按百分比减少伤害，减少的伤害不能超过当前层

return {
    -- 返回的是提升的攻击点数
    apply = function(prop, baseValue)
        if (prop[3] == 0) then
            return 0;
        end

        -- 降低的千分比
        local v = math.modf(baseValue * prop[3] / 1000);

        -- 最少减少1点伤害
        v = math.max(1, v);

        -- 返回减少的值，不能高于伤害
        return math.min(v,baseValue);
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;

        local key = FormulaM.invoke("CALC_SKILL_APPEND_PROP", 1);
        if key and prop[2] ~= "equip" then
            local p = PropM.combine(ME.user, key, 1);
            local append = math.modf(PropM.apply(p, 1) / 10);
            if append > 0 then
                desc = row.append_desc;
                desc = string.gsub(desc, "{append}", append);
            end
        end

        local v = math.modf(prop[3] / 10);
        desc = string.gsub(desc, "{1}", v);

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end
};